﻿//删除成员行
function DelRowApplication(obj)
{   
   	//alert(obj.parentNode.parentNode.parentNode.parentNode.nodeName);
	table=obj.parentNode.parentNode.parentNode.parentNode;
	table.parentNode.removeChild(table)
	TotleincomeAfterDel();
    peoplenum=getPeopleNum();    
}

//删除房屋
function DelRowHousing(obj)
{
	table=obj.parentNode.parentNode.parentNode.parentNode;
	//alert(table.id.toString());
	table.parentNode.removeChild(table)
	
//    //TotleincomeAfterDel("txbincome"+row);
//    var node = document.getElementById("HousingNode"+row)
//    var obj = node.childNodes;
//    while(node.firstChild!=null)
//    {
//        node.removeChild(node.firstChild);
//    }
//   
}

//得到房屋数 
function getHouseNum()
{
	obj=document.getElementById("houses");
	var arr=obj.getElementsByTagName("input");
	var count=0;
	for(var i=0;i<arr.length;i++)
	{
		//alert(arr[i].id.toString().substring(0,11))
		if(arr[i].id.toString().substring(0,11)=="ckbaddcount") 
			count++;
	}
	return count;	
}

//得到房屋面积数-参与计算
function getHouseTotalArea()
{
	var areanum=0;
	obj=document.getElementById("houses");
	var arr=obj.getElementsByTagName("input");
	for(var i=0;i<arr.length;i++)
	{
		//alert(arr[i].id.toString().substring(0,11))
		if(arr[i].id.toString().substring(0,11)=="ckbaddcount"&&arr[i].checked==true) 
		{
			//alert(arr[i].parentNode.parentNode.firstChild.nextSibling.nextSibling.firstChild.id);
			areanum=areanum+Number(arr[i].parentNode.parentNode.firstChild.nextSibling.nextSibling.firstChild.value);
		}
	}
	 //alert(areanum)
	document.getElementById("txbtotlearea").value=areanum;
    document.getElementById("txbavgarea").value=(areanum/getPeopleNum()).toFixed(2);	
}



function TotleincomeAfterDel(str)
{
		total=getPeopleIsproTotalIncoming()
		isproNum=getPeopleIsproNum()
		avgyear=total/isproNum		
		if(isNaN(avgyear))
			avgyear=0;
		avgmonth=(total/isproNum)/12		
		if(isNaN(avgmonth))
			avgmonth=0;			
		avgyear=avgyear.toFixed(2);
		avgmonth=avgmonth.toFixed(2);
		document.getElementById("txbtotleincome").value=total;
		document.getElementById("txbpeoplenumIsPro").value=isproNum;
		document.getElementById("txbpeoplenum").value=getPeopleNum();
		document.getElementById("txbavgincome").value=avgyear;
		document.getElementById("txbavgmonthincome").value=avgmonth; 
}
//验证是否为空
function   Check()   
{  	
			if((getPeopleIsproTotalIncoming()/getPeopleIsproNum())>11386.8)
						{
							 alert("保障人均年收入不能大于11386.8");
							 return false;
							//document.getElementById(str).value="0"
			//				total=getPeopleIsproTotalIncoming()
			//				//重新计算
			//				isproNum=getPeopleIsproNum()
			//				avgyear=total/isproNum
			//				if(isNaN(avgyear))
			//					avgyear=0;
			//				avgmonth=(total/isproNum)/12
			//				if(isNaN(avgmonth))
			//					avgmonth=0;
				
			}
			
			
			
    if(document.form1.txbaddress.value=="")   
    {   
      alert("户籍地址不能为空!"); 
	  document.form1.txbaddress.focus();
      return   false;   
    }
    if(document.form1.txbname.value=="")   
    {   
      alert("申请人姓名不能为空!"); 
	  document.form1.txbname.focus();
      return   false;
    }   
    if(document.form1.txbcard.value=="")   
    {   
      alert("申请人身份证号码不能为空!"); 
	  document.form1.txbcard.focus();
      return   false;   
    }
	//家庭成员判断
	tempPeopleNum=getPeopleNum();
	if(tempPeopleNum>1)
	{
		for(i=1;i<tempPeopleNum;i++)
		{
			if(document.getElementById("txbapplytitle"+i).value=="")
			{
				alert("称谓不能为空!"); 
				document.getElementById("txbapplytitle"+i).focus();
				return false;
			}	
			if(document.getElementById("txbname"+i).value=="")
			{
				alert("姓名不能为空!"); 
				document.getElementById("txbname"+i).focus();
				return false;
			}	
			if(document.getElementById("txbcard"+i).value=="")
			{
				alert("身份证号码不能为空!"); 
				document.getElementById("txbcard"+i).focus();
				return false;
			}	
			
		}
	}	
    if(document.form1.txbapplytime.value=="")   
    {   
      alert("申请时间不能为空!"); 
	  document.form1.txbapplytime.focus();
      return   false;   
    }
    
     if(document.form1.apply_longid.value=="")   
    {   
      alert("审核表编号不能为空!");
	  document.form1.apply_longid.focus();
      return   false;   
    }
    var result=false;
    var opts = document.all("rbldoc");
    if(opts)   
    {   
        for(var i = 0; i < opts.length; i++)   
        {   
            if (opts[i].checked)   
            {      
                result=true;
                break;   
            }   
        }   
    }
    if(opts)
    {
        for(var i = 1; i < 4; i++)
        {
            var proofnum=document.getElementById("txbproofnum").value;
            if(opts[i].checked && proofnum =="")
            {
                alert("证件号不能为空");
                return false;
            }
        }
    }
    if(result==false)
    {
         alert('请选择证件材料');
         return false;
    }
    if(mess!="")
    {
        alert(mess);
        return false;
    }
    return true;
}



function docYearClick(index)
{
	document.getElementById("ddlyear1").selectedIndex=index;
	document.getElementById("ddlyear2").selectedIndex=index;
	document.getElementById("ddlyear3").selectedIndex=index;
	
}
function docMonthClick(index)
{
	document.getElementById("ddlmonth1").selectedIndex=index;
	document.getElementById("ddlmonth2").selectedIndex=index;
	document.getElementById("ddlmonth3").selectedIndex=index;
	
}